package com.ruoyi.data.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.data.domain.DataInventoryRecord;
import com.ruoyi.data.mapper.DataInventoryRecordMapper;
import com.ruoyi.data.service.IDataInventoryRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 库存记录Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-03
 */
@Service
public class DataInventoryRecordServiceImpl implements IDataInventoryRecordService {
    @Autowired
    private DataInventoryRecordMapper dataInventoryRecordMapper;

    /**
     * 查询库存记录
     *
     * @param id 库存记录主键
     * @return 库存记录
     */
    @Override
    public DataInventoryRecord selectDataInventoryRecordById(Long id) {
        return dataInventoryRecordMapper.selectDataInventoryRecordById(id);
    }

    /**
     * 查询库存记录列表
     *
     * @param dataInventoryRecord 库存记录
     * @return 库存记录
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<DataInventoryRecord> selectDataInventoryRecordList(DataInventoryRecord dataInventoryRecord) {
        return dataInventoryRecordMapper.selectDataInventoryRecordList(dataInventoryRecord);
    }

    /**
     * 新增库存记录
     *
     * @param dataInventoryRecord 库存记录
     * @return 结果
     */
    @Override
    public int insertDataInventoryRecord(DataInventoryRecord dataInventoryRecord) {
        dataInventoryRecord.setCreateTime(DateUtils.getNowDate());
        return dataInventoryRecordMapper.insertDataInventoryRecord(dataInventoryRecord);
    }

    /**
     * 修改库存记录
     *
     * @param dataInventoryRecord 库存记录
     * @return 结果
     */
    @Override
    public int updateDataInventoryRecord(DataInventoryRecord dataInventoryRecord) {
        dataInventoryRecord.setUpdateTime(DateUtils.getNowDate());
        return dataInventoryRecordMapper.updateDataInventoryRecord(dataInventoryRecord);
    }

    /**
     * 批量删除库存记录
     *
     * @param ids 需要删除的库存记录主键
     * @return 结果
     */
    @Override
    public int deleteDataInventoryRecordByIds(Long[] ids) {
        return dataInventoryRecordMapper.deleteDataInventoryRecordByIds(ids);
    }

    /**
     * 删除库存记录信息
     *
     * @param id 库存记录主键
     * @return 结果
     */
    @Override
    public int deleteDataInventoryRecordById(Long id) {
        return dataInventoryRecordMapper.deleteDataInventoryRecordById(id);
    }
}
